﻿using SmartAddressLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SmartAddressTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text))
            {
                MessageBox.Show("请输入需要解析的地址！");
            }
            else
            {
                AddressParser.MakePrioritySort(p =>
                {
                    switch (p.Name)
                    {
                        case "山东省":
                            return 0;

                        case "江苏省":
                            return 1;

                        case "上海市":
                            return 2;
                            //......
                    }
                    return 99;
                });
                var matchitems = AddressParser.ParsingAddress(textBox1.Text);
                foreach (var matchitem in matchitems)
                {
                    textBox2.Text += matchitem + "\r\n";
                    textBox2.Text += AddressParser.FinalCut(matchitem, textBox1.Text) + "\r\n";
                }
            }
        }
    }
}
